package com.xin.components
{
	import com.xin.components.base.ButtonBase;

	/**
	 * 文本按钮
	 * @author xin
	 */
	public class TextButton extends ButtonBase
	{
		protected var _label:Label;
		private var _text:String;
		
		public function TextButton(w:uint, h:uint, text:String = "", clickHandler : Function = null)
		{
			_text = text;
			super(w, h, clickHandler);
		}
		
		override protected function addChildren() : void
		{
			super.addChildren();
			
			_label = new Label(_text);
			addChild(_label);
		}
		
		override public function draw() : void
		{
			super.draw();
			
			_label.x = (_width - _label.width) * .5;
			_label.y = (_height - _label.height) * .5;
		}
		
		/**
		 * @return 按钮文本
		 */
		public function get text():String
		{
			return _label.text;
		}

	}
}
